<template>
  <div class="app-message-box"></div>
</template>

<script lang="ts">
import {
  Vue,
  Component,
  Prop,
  Provide,
  Emit,
  Watch
} from "vue-property-decorator";
import { Subject } from "rxjs";
import { MessageBox } from "mint-ui";

@Component({
  components: {}
})
export default class AppPrompt extends Vue {
  /**
   * 显示
   *
   * @memberof AppPrompt
   */
  public show(
    content: any,
    back: any
  ) {
    
    content = this.innit(content);
    //获取内容
    MessageBox.confirm("", {
      title: content.title,
      message: content.message,
      showCancelButton: content.showCancelButton,
      confirmButtonText: content.confirmButtonText,
      cancelButtonText: content.cancelButtonText,
      showConfirmButton:content.showConfirmButton
    })
      .then((action: any) => {
        if (action == "confirm") {
          content.confirm();
        }
      })
      .catch((error: any) => {
        if (error == "cancel") {
          content.cancel();
        }
      });
  }
  /**
   * 逻辑判断
   *
   * @memberof AppPrompt
   */
  public innit(content:any) {
    //标题
    if (!content.title) {
       content.title = "提示";
    }
    //内容
    if (!content.message) {
       content.message = "确定执行此操作?";
    }
    //确定按钮
    if (!content.confirmButtonText) {
       content.confirmButtonText = "确定";
    }
    //取消按钮
    if (!content.cancelButtonText) {
       content.cancelButtonText = "取消";
    }
    //按钮是否显示
    if (content.showCancelButton == null || content.showCancelButton == undefined) {
       content.showCancelButton = true;
    }
    //按钮是否显示
    if (content.showConfirmButton == null || content.showConfirmButton == undefined) {
       content.showConfirmButton = true;
    }
    return content;
  }
  
}
</script>

<style lang="less">
  .v-modal{
    z-index:2222 !important;
  }
  .mint-msgbox-wrapper{
    z-index:2223 !important; 
  }
</style>